---
layout: blank
hide-in-nav: true
---
<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Music Score | Chase</title>
  <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
  <style>
    #html,
    #body {
      margin: 0;
      padding: 0;
      user-seletct: none;
      -webkit-user-seletct: none;
      -moz-user-seletct: none;
      -ms-user-seletct: none;
    }

    .pics-container {
      width: 100%;
    }

    .pics-container img {
      width: 100%;
    }

    .scores {
      display: flex;
      flex-wrap: wrap;
      padding: 0;
      margin: 0;
    }

    .scores li {
      flex-grow: 1;
      list-style-type: none;
      padding: 20px;
      margin: 2%;
      background: whitesmoke;
      border-radius: 20px;
      transition: .3s;
      color: gray;
      text-align: center;
      font-size: 26px;
      font-weight: bolder;
    }

    .scores li:hover {
      transform: scale(.9);
    }

    .back {
      padding: 20px;
      margin: 2%;
      background: whitesmoke;
      border-radius: 20px;
      transition: .3s;
      color: gray;
      font-size: 26px;
      font-weight: bolder;
      text-align: center;
    }

    .back:hover {
      transform: scale(.9);
    }

    .search-container {
      display: flex;
      width: 100%;
      padding: 2%;
      box-sizing: border-box;
      align-items: center;
      justify-content: center;
    }

    .search-input {
      background: whitesmoke;
      color: gray;
      text-align: center;
      border-radius: 20px;
      border: none;
      flex: 1;
      font-size: 24px;
      height: 40px;
    }

    .search-button {
      width: 30px;
      height: 30px;
      margin: 0 0 0 20px;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- Search -->
    <div v-if="flagShowSearch" class="search-container">
      <input class="search-input" v-model="searchContent" type="text" @keyup.enter="search(searchContent)">
      <div class="search-button" @click="search(searchContent)">
        <svg t="1638534704545" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
          p-id="3028" width="30" height="30">
          <path
            d="M930.56 749.44l-160-103.36A400.96 400.96 0 1 0 646.08 768l103.36 160a133.44 133.44 0 0 0 39.36 39.36 130.88 130.88 0 0 0 141.76-220.48zM432 704a272 272 0 1 1 272-272 272 272 0 0 1-272 272z"
            fill="#808080" p-id="3029"></path>
        </svg>
      </div>
    </div>
    <div class="back" v-if="flagShowBack" @click="back">返回</div>

    <!-- ScoreList -->
    <ul class="scores" v-if="flagShowList">
      <li v-for="(value, key, index) in scores" @click="navigateToScoreOn(key)">
        <div :id="key"></div>
      </li>
    </ul>

    <div v-if="flagShowPicsContainer" class="pics-container">
      <img v-for="value in scores[picsIndex].pics" :src="value" alt="100%">
    </div>
    <div class="back" v-if="flagShowBack" @click="back">back</div>
  </div>
</body>
<script>
  const PREFIX = '/img/music-score';
  new Vue({
    el: '#app',
    data: {
      flagShowList: true,
      flagShowBack: false,
      flagShowPicsContainer: false,
      flagShowSearch: true,
      picsIndex: 0,
      searchContent: '',
      metaScores: [{
          name: `其他`,
          pics: [`${PREFIX}/其他/俄罗斯国歌.jpg`, `${PREFIX}/其他/国歌.jpg`, `${PREFIX}/其他/我和我的祖国.jpg`,
            `${PREFIX}/其他/我的祖国.jpg`, `${PREFIX}/其他/雪绒花吉他谱.jpg`
          ]
        },
        {
          name: `大鱼`,
          pics: [`${PREFIX}/大鱼/大鱼_1.jpg`, `${PREFIX}/大鱼/大鱼_2.jpg`, `${PREFIX}/大鱼/大鱼_简谱.jpg`]
        },
        {
          name: `岁月神偷`,
          pics: [`${PREFIX}/岁月神偷/岁月神偷_1_1.png`, `${PREFIX}/岁月神偷/岁月神偷_1_2.png`, `${PREFIX}/岁月神偷/岁月神偷_2_1.png`,
            `${PREFIX}/岁月神偷/岁月神偷_2_2.png`
          ]
        },
        {
          name: `年少有为`,
          pics: [`${PREFIX}/年少有为/年少有为_1_1.png`, `${PREFIX}/年少有为/年少有为_1_2.png`, `${PREFIX}/年少有为/年少有为_1_3.png`,
            `${PREFIX}/年少有为/年少有为_2_1.png`, `${PREFIX}/年少有为/年少有为_2_2.png`
          ]
        },
        {
          name: `爱尔兰画眉`,
          pics: [`${PREFIX}/爱尔兰画眉/爱尔兰画眉_0.jpg`, `${PREFIX}/爱尔兰画眉/爱尔兰画眉吉他.jpg`, `${PREFIX}/爱尔兰画眉/爱尔兰画眉吉他谱_六线 
谱_秋野_C调_1.png`, `${PREFIX}/爱尔兰画眉/爱尔兰画眉吉他谱_六线谱_秋野_C调_2.png`, `${PREFIX}/爱尔兰画眉/爱尔兰画眉吉他谱_六线谱_秋野_C调_3.png`]
        },
        {
          name: `等你下课`,
          pics: [`${PREFIX}/等你下课/等你下课_1_1.png`, `${PREFIX}/等你下课/等你下课_1_2.png`, `${PREFIX}/等你下课/等你下课_2_1.jpg`,
            `${PREFIX}/等你下课/等你下课_2_2.jpg`
          ]
        },
        {
          name: `老男孩`,
          pics: [`${PREFIX}/老男孩/老男孩_1_1.jpg`, `${PREFIX}/老男孩/老男孩_1_2.jpg`, `${PREFIX}/老男孩/老男孩_1_3.jpg`]
        },
        {
          name: `蒲公英的约定`,
          pics: [`${PREFIX}/蒲公英的约定/蒲公英的约定_1_1.jpg`, `${PREFIX}/蒲公英的约定/蒲公英的约定_1_2.jpg`]
        },
        {
          name: `说谎`,
          pics: [`${PREFIX}/说谎/说谎_1_1.jpg`, `${PREFIX}/说谎/说谎_1_2.jpg`]
        },
        {
          name: `静悄悄`,
          pics: [`${PREFIX}/静悄悄/静悄悄_1_1.jpg`, `${PREFIX}/静悄悄/静悄悄_1_2.jpg`, `${PREFIX}/静悄悄/静悄悄_1_3.jpg`]
        },
      ],
      scores: []
    },
    beforeMount() {
      this.scores = this.metaScores;
    },
    mounted() {
      if (this.flagShowList) {
        for (const key in this.scores) {
          if (Object.hasOwnProperty.call(this.scores, key)) {
            const element = this.scores[key];
            document.getElementById(key).innerHTML = element.name;
          }
        }
      }

      if (window.history && window.history.pushState) {
        // 向历史记录中插入了当前页，这样才能返回
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', this.goBack, false);
      }
    },

    destroyed() {
      window.removeEventListener('popstate', this.goBack, false);
    },

    updated() {
      if (this.flagShowList) {
        for (const key in this.scores) {
          if (Object.hasOwnProperty.call(this.scores, key)) {
            const element = this.scores[key];
            document.getElementById(key).innerHTML = element.name;
          }
        }
      }
    },
    methods: {
      back() {
        this.flagShowList = !this.flagShowList;
        this.flagShowBack = !this.flagShowBack;
        this.flagShowPicsContainer = !this.flagShowPicsContainer;
        this.flagShowSearch = !this.flagShowSearch;
        // // 搜索复原
        // this.searchContent = '';
        // this.search(this.searchContent);
      },
      navigateToScoreOn(key) {
        this.picsIndex = key;
        this.flagShowList = !this.flagShowList;
        this.flagShowBack = !this.flagShowBack;
        this.flagShowPicsContainer = !this.flagShowPicsContainer;
        this.flagShowSearch = !this.flagShowSearch;
      },
      goBack() {
        // 返回
        this.back();
        sessionStorage.clear();
        window.history.back();
        history.pushState(null, null, document.URL);
      },
      search(content) {
        if (content == '') {
          this.scores = this.metaScores;
          return;
        }

        this.scores = [];

        this.scores = this.metaScores.filter((element, index) => {
          if (index == 0) {
            console.log(1);
            return element.name.indexOf(content) != -1 || element.pics.some(pic => {
              return pic.indexOf(content, pic.lastIndexOf('/') + 1) != -1;
            })
          } else {
            return element.name.indexOf(content) != -1
          }
        })
      }
    }
  });
</script>

</html>